﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Modules.guide.ui {
    import flash.events.*;
    import Engine.Managers.*;
    import flash.display.*;
    import Events.*;
    import Display.DialogUI.*;
    import org.aswing.*;
    import Classes.*;
    import Classes.util.*;
    import flash.text.*;
    import org.aswing.event.*;
    import org.aswing.border.*;
    import Display.aswingui.*;

    public class InviteFriendsGuideDialog extends WelcomeDialog {

        public function InviteFriendsGuideDialog(_arg1:String, _arg2:String="", _arg3:int=0, _arg4:Function=null, _arg5:Boolean=true, _arg6:String="", _arg7:String="", _arg8:Function=null){
            super(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8);
        }
        override protected function createButtonPanel():JPanel{
            var _local2:CustomButton;
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            if (m_SkipCallback != null){
                _local2 = new CustomButton(ZLoc.t("Dialogs", "Skip"), null, "GreyButtonUI");
                _local2.setPreferredWidth(100);
                _local2.setMinimumWidth(100);
                _local2.setMaximumWidth(100);
                _local2.addActionListener(this.onSkip, 0, true);
                _local1.append(_local2);
                _local1.append(ASwingHelper.horizontalStrut(5));
            };
            m_button = new CustomButton(ZLoc.t("Dialogs", "InviteNeighbors"), null, "GreenButtonUI");
            m_button.addActionListener(this.onPanelClick, 0, true);
            _local1.append(m_button);
            return (_local1);
        }
        protected function onSkip(_arg1):void{
            countDialogAction("X");
            var _local2:GenericPopupEvent = new GenericPopupEvent(GenericPopupEvent.SELECTED, GenericDialogView.SKIP, true);
            dispatchEvent(_local2);
            if (m_SkipCallback != null){
                removeEventListener(GenericPopupEvent.SELECTED, m_SkipCallback);
            };
            super.closeMe(new Event("close", true));
        }
        override protected function getTfWidth(_arg1:String, _arg2:String):int{
            return (Math.max(300, (_arg1.length * 1.5), (_arg2.length * 1.5)));
        }
        override protected function onPanelClick(_arg1:AWEvent):void{
            FrameManager.showTray("invite.php?ref=ftue_neighbor_prompt");
            super.onPanelClick(_arg1);
        }
        override protected function onAssetsLoaded(_arg1:Event=null):void{
            var _local10:AssetPane;
            var _local2:Object = m_loaderObj;
            m_advisor = m_avatarContent;
            m_speech = (new _local2.speechBubbleLeft() as DisplayObject);
            m_jpanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
            var _local3:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.CENTER);
            var _local4:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.CENTER);
            _local3.setBackgroundDecorator(new MarginBackground(m_speech, new Insets(20, 0, 10, 0)));
            var _local5:int = this.getTfWidth(m_message, m_dialogTitle);
            var _local6:JPanel = this.createCloseButtonPanel();
            var _local7:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.RIGHT);
            _local7.append(_local6);
            if (m_dialogTitle){
                _local10 = ASwingHelper.makeMultilineCapsText(m_dialogTitle, _local5, EmbeddedArt.TITLE_FONT, TextFormatAlign.LEFT, 16, EmbeddedArt.darkBlueTextColor, null, true);
                _local4.append(_local10);
            };
            var _local8:AssetPane = ASwingHelper.makeMultilineText(m_message, _local5, EmbeddedArt.DEFAULT_FONT_NAME_BOLD, TextFormatAlign.LEFT, 16, EmbeddedArt.brownTextColor, null, true);
            _local4.appendAll(_local8, ASwingHelper.verticalStrut(10));
            _local4.setBorder(new EmptyBorder(null, new Insets(10, 50, 0, 25)));
            var _local9:JPanel = this.createButtonPanel();
            _local4.append(_local9);
            _local3.append(ASwingHelper.verticalStrut(15));
            _local3.append(_local7, BorderLayout.EAST);
            _local3.append(ASwingHelper.verticalStrut(-18));
            _local3.append(_local4);
            ASwingHelper.prepare(_local3);
            m_jpanel.append(_local3);
            this.finalizeAndShow();
        }
        protected function createCloseButtonPanel():JPanel{
            var _local1:JPanel = new JPanel(ASwingHelper.softBoxLayoutVertical);
            var _local2:JButton = ASwingHelper.makeMarketCloseButton();
            _local2.addEventListener(MouseEvent.CLICK, this.onSkip, false, 0, true);
            _local1.append(_local2);
            ASwingHelper.setEasyBorder(_local2, 0, 0, 0, 0);
            return (_local1);
        }
        override protected function finalizeAndShow():void{
            StatsManager.milestone("first_invite_friends");
            super.finalizeAndShow();
        }

    }
}//package Modules.guide.ui 
